<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>增加学生</title>
		<link rel="stylesheet" type="text/css" href="js/layui/css/layui.css"/>
		<script src="js/jquery-1.11.3.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/layer/layer.js" type="text/javascript" charset="utf-8"></script>
		
	</head>
	<body>
		
		<div id="add-Stuent" style="" >
		       <form class="layui-form" id="add-form" action="">
		         <div class="layui-form-item center" >
		          <label class="layui-form-label" style="width: 100px" >用户账号</label>
		          <div class="layui-input-block">
		           <input type="text" name="name" id="AccountName" style="width: 240px" lay-verify="required" placeholder="请输入账号名称" autocomplete="off" class="layui-input">
		          </div>
		         </div>
		         <div class="layui-form-item">
		          <label class="layui-form-label" style="width: 100px">用户密码</label>
		          <div class="layui-input-block">
		           <input type="text" name="type" id="AccountPass" required style="width: 240px" lay-verify="required" placeholder="请输入用户密码" autocomplete="off" class="layui-input">
		          </div>
		         </div>
				    <div class="layui-form-item">
				  <label class="layui-form-label" style="width: 100px">确认密码</label>
				  <div class="layui-input-block">
				   <input type="text" name="type" id="AccountPass1" required style="width: 240px" lay-verify="required" placeholder="请确认密码" autocomplete="off" class="layui-input">
				  </div>
				 </div>
				 
				 
				   <div class="layui-form-item">
				  <label class="layui-form-label">用户类型</label>
				 <div class="layui-input-block" style="width: 240px"">
				   <select name="city" lay-verify="required" id="Type" lay-filter='test'>
				     <option value="">请选择</option>
				     <option value="2">学生</option>
				    <option value="3">老师</option>
				    				    
				   </select>
				 </div>
				 </div>
				 				   <div class="layui-form-item">
				  <label class="layui-form-label">类型id</label>
				 <div class="layui-input-block" style="width: 240px"">
				   <select name="city3" lay-verify="required" id="student2" >
				     <option value="">请选择</option>
				    <!-- <option value="2">学生</option>
				    <option value="3">老师</option> -->
				    				    
				   </select>
				 </div>
				 </div>
                
		       
			   
			   
		       
		       </form>  
			   
			   
		    </div>
			 <button class="layui-btn " style="margin-left:100px;" id="studentSave1">保存</button>
	</body>
	
<script>//Demo
layui.use('form', function(){
  var form = layui.form;
  
  //监听提交
  form.on('submit(formDemo)', function(data){
    layer.msg(JSON.stringify(data.field));
    return true;
  });
});
</script>
<script type="text/javascript">

     $(document).ready(function(){
		 
		
		 
		 
		 
		 
		 
		 
		$("#studentSave1").click(function(){
			if($("#AccountName").val()==""||$("#AccountName").val()==null){
				layer.msg("用户名不能为空", {time:1000, icon:5, shift:6},function(){
					
				});
				return;
			} else if($("#AccountPass").val()==""||$("#AccountPass").val()==null){
				layer.msg("密码不能为空", {time:1000, icon:5, shift:6},function(){
					
				});
				return;
			} else if($("#AccountPass").val()!=$("#AccountPass1").val()){
				layer.msg("密码不一致", {time:1000, icon:5, shift:6},function(){
					
				});
				return;
			}else if($("#teach3").val()!=2&&$("#teach3").val()!=3){
				layer.msg("请选择类型", {time:1000, icon:5, shift:6},function(){
					
				});
				return;
			} else{
				var data={
					"username":$("#AccountName").val(),
					"password":$("#AccountPass").val()
				}
				$.ajax({
					type:"post",
					url:"http://127.0.0.1:8080/user/login",
					dataType: 'json',
					contentType: "application/json;charset=utf-8",
					   
					data: JSON.stringify(data),
					success:function(msg){
							layer.msg(msg.data, {time:1000, icon:5, shift:6},function(){
								
							});
						}
				})
			}
		}) 
		 
		 
		
		 
	 })
  
   
   
   
		
	</script>
	
	
	
			
	
	
	
	
	
</html>
 